<template>
  <div class="recommend-list">
    <p>{{ title }}</p>
    <div class="list-content">
      <div class="list-item" v-for="item in cardList" :key="item.id">
        <img :src="item.imgHost+item.imgUrl" alt="" />
        <a href="javascript:;" @click="handleDetails(item.path,'/content-article/'+item.id)">{{ item.title }}</a>
      </div>
    </div>
  </div>
</template>

<script>
import { mapActions, mapMutations } from "vuex";
export default {
  props: {
    title: String,
    cardList: Array,
  },
  data() {
    return {};
  },
  methods:{
    ...mapActions(['handleSetActiveArr']),
    async handleDetails(path, pathId) {
      await this.handleSetActiveArr({path,app:this})
      if (pathId) {
        this.$router.push({
          path:pathId
        });
      } else {
        this.$router.push({
          path
        });
      }
    },
  }
};
</script>

<style lang="less" scoped>
.recommend-list {
  width: 100%;
  margin-top: 20px;
  box-sizing: border-box;
  background: #fff;
  overflow: hidden;
  padding-bottom: 15px;
  p {
    border-left: 4px solid #0088cc;
    padding-left: 10px;
    margin: 15px;
  }
  .list-content {
    .list-item {
      display: inline-block;
      width: 50%;
      border: 15px solid #fff;
      border-top: 0;
      box-sizing: border-box;
      overflow: hidden;
      img {
        width: 100%;
        transition: transform 0.5s;
        &:hover {
          transform: scale(1.02);
        }
      }
      a {
        height: 42px;
        font-size: 14px;
        white-space: normal;
        box-sizing: border-box;
        color: #000;
        &:hover {
          color: #3361ea;
        }
        line-height: 1.4;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
      }
    }
  }
}
</style>